﻿
/// <summary>
/// WebApplication 的摘要描述
/// </summary>
using NHibernate;
using System.IO;
using System.Web.Hosting;
using com.pro2e.console.service.auth.vo;
using log4net.Repository.Hierarchy;
using log4net.Appender;
using log4net;
using com.pro2e.console.generic.log;

namespace com.pro2e.web.config.init
{
    public class WebApplication
    {
        public static readonly NHibernate.Cfg.Configuration Configuration;
        public static readonly ISessionFactory SessionFactory;
        public static readonly string LOCATION = "~/App_Code/";

        static WebApplication()
        {
            Log4net.WebConfigBaseConfig();      
                          
            Configuration = new NHibernate.Cfg.Configuration()
                .SetDefaultAssembly(typeof(LoginUser).Assembly.FullName)
                .AddDirectory(new DirectoryInfo(HostingEnvironment.MapPath(LOCATION)));            


            SessionFactory = Configuration.BuildSessionFactory();
        

        }

        public static ISession GetCurrentSession()
        {
            return SessionFactory.GetCurrentSession();
        }
    }
}